package com.pucheng.bracelet.ui.activity.heartrate

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.pucheng.bracelet.R
import com.pucheng.bracelet.app.util.StatusBarUtil
import com.pucheng.bracelet.app.util.click
import com.pucheng.bracelet.ui.fragment.heartrate.AllDayHeartRateToDayFragment
import com.pucheng.bracelet.ui.fragment.heartrate.AllDayHeartRateToMonthFragment
import com.pucheng.bracelet.ui.fragment.heartrate.AllDayHeartRateToWeekFragment
import com.pucheng.bracelet.viewmodel.steps.StepsViewModel
import kotlinx.android.synthetic.main.activity_hertrate.*
import kotlinx.android.synthetic.main.include_viewpager_sleep.*
import kotlinx.android.synthetic.main.layout_title.*
import me.hgj.jetpackmvvm.base.activity.BaseVmActivity
import me.hgj.jetpackmvvm.demo.app.ext.bindViewPager2
import me.hgj.jetpackmvvm.demo.app.ext.initToActivity

class AllDayHeartRateActivity : BaseVmActivity<StepsViewModel>(){
    override fun createObserver() {

    }

    override fun dismissLoading() {
    }

    override fun initView(savedInstanceState: Bundle?) {
        StatusBarUtil.setColor(this,resources.getColor(R.color.heartrate_bg),0)
        tv_title.text = getString(R.string.all_day_hr)
        ibtn_right.click { startActivity(Intent(this,AllDayHRHistoryActivity::class.java))}
        ibtn_back.click { finish() }
        layout_title.setBackgroundColor(resources.getColor(R.color.heartrate_bg))
        magic_indicator.setBackgroundResource(R.color.heartrate_bg)
        //标题集合
        var mDataList: ArrayList<String> = arrayListOf()
        mDataList.add("日")
        mDataList.add("周")
        mDataList.add("月")
        var fragments: ArrayList<Fragment> = arrayListOf()
        fragments.add(AllDayHeartRateToDayFragment.newInstance())
        fragments.add(AllDayHeartRateToWeekFragment.newInstance())
        fragments.add(AllDayHeartRateToMonthFragment.newInstance())
        //初始化viewpager2
        view_pager.initToActivity(this, fragments)
        //初始化 magic_indicator
        magic_indicator.bindViewPager2(view_pager, mDataList)
    }

    override fun layoutId(): Int = R.layout.activity_heartrate_to_allday

    override fun showLoading(message: String) {
    }

}